home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #14 / Monster Media No. 14 (April 1996) (Monster Media, Inc.).ISO / prog_d / isamexpt.zip / ISAMEDIT.PAS < prev    next >
Pascal/Delphi Source File  |  1996-01-13  |  49KB  |  1,311 lines

  1. unit Isamedit;
  2.  
  3. interface
  4.  
  5. uses WinTypes, WinProcs, Classes, Graphics, Forms, Controls, Buttons,
  6.   StdCtrls, Dialogs, IsamTabl, IStreams;
  7.  
  8. type
  9.   TEditorExperte = class(TForm)
  10.     OKBtn: TBitBtn;
  11.     CancelBtn: TBitBtn;
  12.     GroupBox2: TGroupBox;
  13.     EdiFontLabel: TLabel;
  14.     EdiInputFontLabel: TLabel;
  15.     SpeedButton5: TSpeedButton;
  16.     SpeedButton6: TSpeedButton;
  17.     GroupBox6: TGroupBox;
  18.     LabelNebenRadio: TRadioButton;
  19.     LabelueberRadio: TRadioButton;
  20.     GroupBox7: TGroupBox;
  21.     LenFestRadio: TRadioButton;
  22.     LenVarRadio: TRadioButton;
  23.     FontDialog1: TFontDialog;
  24.     GroupBox1: TGroupBox;
  25.     FormNameInput: TEdit;
  26.     procedure SpeedButton5Click(Sender: TObject);
  27.     procedure SpeedButton6Click(Sender: TObject);
  28.     procedure OKBtnClick(Sender: TObject);
  29.     procedure FormShow(Sender: TObject);
  30.   private
  31.     function CreateSource(const UnitIdent, FormIdent: string): TMemoryStream;
  32.     function CreateForm(const FormIdent: string): TMemoryStream;
  33.   public
  34.     FTable: TIsamTable;
  35.     FormIdent,UnitIdent,FileName: String;
  36.     constructor Create(AOwner: TComponent); override;
  37.     destructor destroy; override;
  38.   end;
  39.  
  40. var
  41.   EditorExperte: TEditorExperte;
  42.  
  43. implementation
  44.  
  45. {$R *.DFM}     
  46.  
  47. Uses SysUtils, ExtCtrls, Proxies, ExptIntf, UToolDll,
  48.      Db, ToolIntf;
  49.  
  50. Const SourceBufferSize = 4096;
  51. var SourceBuffer: PChar;
  52.  
  53. procedure FmtWrite(Stream: TStream; Fmt: PChar;
  54.                    const Args: array of const);
  55. begin
  56.   if (Stream <> nil) and (SourceBuffer <> nil) then
  57.   begin
  58.     StrLFmt(SourceBuffer, SourceBufferSize, Fmt, Args);
  59.     Stream.Write(SourceBuffer[0], StrLen(SourceBuffer));
  60.   end;
  61. end;
  62.  
  63. Function GetFieldTypEditor(S: String;
  64.                            var FieldName: String;
  65.                            var FieldDataType: TFieldType;
  66.                            var Len: Integer): Byte;
  67. var G: Byte;
  68.     Code: Integer;
  69.     SStr: String;
  70. begin
  71.   SStr:= UpperCase(S);
  72.   if Pos('DATUM',SStr) > 0 then begin
  73.     G:= 1;
  74.     FieldDataType:= ftDate;
  75.     Len:= 10;
  76.   end
  77.   else if (Pos('REAL',SStr) > 0) or (Pos('INTEGER',SStr) > 0)
  78.   or (Pos('BYTE',SStr) > 0) or (Pos('WORD',SStr) > 0)
  79.   or (Pos('LONGINT',SStr) > 0) then begin
  80.     G:= 2;
  81.     if Pos('REAL',SStr) > 0 then begin
  82.       FieldDataType:= ftFLOAT;
  83.       Len:= 10;
  84.     end
  85.     else if Pos('INTEGER',SStr) > 0 then begin
  86.       FieldDataType:= ftSMALLINT;
  87.       Len:= 8;
  88.     end
  89.     else if Pos('BYTE',SStr) > 0 then begin
  90.       FieldDataType:= ftSMALLINT;
  91.       Len:= 4;
  92.     end
  93.     else if Pos('WORD',SStr) > 0 then begin
  94.       FieldDataType:= ftWORD;
  95.       Len:= 8;
  96.     end
  97.     else begin
  98.       FieldDataType:= ftINTEGER;
  99.       Len:= 12;
  100.     end;
  101.   end
  102.   else if (Pos('MEMO',SStr) > 0) then begin
  103.     G:= 3;
  104.     FieldDataType:= ftMEMO;
  105.     Len:= 255;
  106.   end
  107.   else begin
  108.     G:= 0;
  109.     FieldDataType:= ftString;
  110.     Strip(SStr);
  111.     Len:= 255;
  112.     if Pos('[',SStr) > 0 then begin
  113.       Delete(SStr,1,Pos('[',SStr));
  114.       if Pos(']',SStr) > 0 then begin
  115.         SStr:= Copy(SStr,1,Pos(']',SStr)-1);
  116.         Val(SStr,Len,Code);
  117.       end;
  118.     end;
  119.   end;
  120.   Strip(S);
  121.   FieldName:= Copy(S,1,Pos(':',S)-1);
  122.   GetFieldTypEditor:= G;
  123. end;
  124.  
  125. function Erzeuge_EditorForm(const FormIdent: string;
  126.                             SrcTable: TIsamTable;
  127.                             Label_Neben_Input: Boolean;
  128.                             InputLen_Fest: Boolean;
  129.                             LFont, EFont: TFont): TForm;
  130. var
  131.   BtnPos   : TPoint;
  132.   Method   : TMethod;
  133.   MP,UP,UP1,UP2,UP3: TPanel;
  134.   SP       : TSpeedButton;
  135.   Tbl      : TIsamTable;
  136.   W,i,Ty,G : Integer;
  137.   SLab     : TLabel;
  138.   {$IFDEF SHAREWARE}
  139.   SInp     : TOvcSimpleField;
  140.   PInp     : TOvcPictureField;
  141.   NInp     : TOvcNumericField;
  142.   {$ELSE}
  143.   SInp     : TEdit;
  144.   PInp     : TEdit;
  145.   NInp     : TEdit;
  146.   {$ENDIF}
  147.   MInp     : TMemo;
  148.   Tm       : TTimer;
  149.   FieldName,SStr: String;
  150.   Len : Integer;
  151.   FieldDataType: TFieldType;
  152. begin
  153.   Result := TProxyForm.CreateAs('T' + FormIdent);
  154.   with Result do begin
  155.     BorderStyle := bsDialog;
  156.     AutoScroll  := True;
  157.     Left:= 100;
  158.     Top:= 101;
  159.     Width := 400;
  160.     Height := 282;
  161.     Position := poScreenCenter;
  162.     Name := FormIdent;
  163.     Caption := FormIdent;
  164.     Method.Code := TProxyForm(Result).CreateMethod('FormCreate');
  165.     Method.Data := Result;
  166.     OnCreate    := TNotifyEvent(Method);
  167.     with Font do begin
  168.       Color := clBlack;
  169.       Height:= -11;
  170.       Name := 'Arial';
  171.       Size := 8;
  172.       Style:= [fsBold];
  173.     end;
  174.  
  175.     {$IFDEF SHAREWARE}
  176.     With TOvcController.Create(Result) do begin
  177.       Name:= 'DefaultController';
  178.     end;
  179.     {$ENDIF}
  180.  
  181.     MP:= TPanel.Create(Result);
  182.     with MP do begin
  183.       Parent := Result;
  184.       Name := 'Panel1';
  185.       Align := alTop;
  186.       ShowHint:= True;
  187.       Caption:= '';
  188.     end;
  189.  
  190.     Sp:= TSpeedButton.Create(Result);
  191.     with SP do begin
  192.       Parent:= MP;
  193.       Left:= 10;
  194.       Top := 8;
  195.       Width := 25;
  196.       Height := 25;
  197.       Hint := 'Zurⁿck';
  198.       Name := 'RueckBttn';
  199.       Glyph.Handle:= LoadBitmap(HInstance,'RUECK');
  200.       Method.Code := TProxyForm(Result).CreateMethod('RueckBttnClick');
  201.       Method.Data := Result;
  202.       Sp.OnClick := TNotifyEvent(Method);
  203.     end;
  204.  
  205.     Sp:= TSpeedButton.Create(Result);
  206.     with SP do begin
  207.       Parent:= MP;
  208.       Left:= 35;
  209.       Top := 8;
  210.       Width := 25;
  211.       Height := 25;
  212.       Hint := 'VorwΣrts';
  213.       Name := 'VorBttn';
  214.       Glyph.Handle:= LoadBitmap(HInstance,'VOR');
  215.       Method.Code := TProxyForm(Result).CreateMethod('VorBttnClick');
  216.       Method.Data := Result;
  217.       Sp.OnClick := TNotifyEvent(Method);
  218.     end;
  219.  
  220.     Sp:= TSpeedButton.Create(Result);
  221.     with SP do begin
  222.       Parent:= MP;
  223.       Left:= 60;
  224.       Top := 8;
  225.       Width := 25;
  226.       Height := 25;
  227.       Hint := 'Suchen';
  228.       Name := 'SuchBttn';
  229.       Glyph.Handle:= LoadBitmap(HInstance,'SUCH');
  230.       Method.Code := TProxyForm(Result).CreateMethod('SuchBttnClick');
  231.       Method.Data := Result;
  232.       Sp.OnClick := TNotifyEvent(Method);
  233.     end;
  234.  
  235.     Sp:= TSpeedButton.Create(Result);
  236.     with SP do begin
  237.       Parent:= MP;
  238.       Left:= 85;
  239.       Top := 8;
  240.       Width := 25;
  241.       Height := 25;
  242.       Hint := 'Sortierordnung';
  243.       Name := 'KeyBttn';
  244.       Glyph.Handle:= LoadBitmap(HInstance,'KEY');
  245.       Method.Code := TProxyForm(Result).CreateMethod('KeyBttnClick');
  246.       Method.Data := Result;
  247.       Sp.OnClick := TNotifyEvent(Method);
  248.     end;
  249.  
  250.     Sp:= TSpeedButton.Create(Result);
  251.     with SP do begin
  252.       Parent:= MP;
  253.       Left:= 110;
  254.       Top := 8;
  255.       Width := 25;
  256.       Height := 25;
  257.       Hint := 'Leeren';
  258.       Name := 'NeuBttn';
  259.       Glyph.Handle:= LoadBitmap(HInstance,'NEU');
  260.       Method.Code := TProxyForm(Result).CreateMethod('NeuBttnClick');
  261.       Method.Data := Result;
  262.       Sp.OnClick := TNotifyEvent(Method);
  263.     end;
  264.  
  265.     Sp:= TSpeedButton.Create(Result);
  266.     with SP do begin
  267.       Parent:= MP;
  268.       Left:= 135;
  269.       Top := 8;
  270.       Width := 25;
  271.       Height := 25;
  272.       Hint := 'Anlegen';
  273.       Name := 'AnlegBttn';
  274.       Glyph.Handle:= LoadBitmap(HInstance,'ANLEGEN');
  275.       Method.Code := TProxyForm(Result).CreateMethod('AnlegBttnClick');
  276.       Method.Data := Result;
  277.       Sp.OnClick := TNotifyEvent(Method);
  278.     end;
  279.  
  280.     Sp:= TSpeedButton.Create(Result);
  281.     with SP do begin
  282.       Parent:= MP;
  283.       Left:= 160;
  284.       Top := 8;
  285.       Width := 25;
  286.       Height := 25;
  287.       Hint := '─ndern';
  288.       Name := 'AendernBttn';
  289.       Glyph.Handle:= LoadBitmap(HInstance,'AENDERN');
  290.       Method.Code := TProxyForm(Result).CreateMethod('AendernBttnClick');
  291.       Method.Data := Result;
  292.       Sp.OnClick := TNotifyEvent(Method);
  293.     end;
  294.  
  295.     Sp:= TSpeedButton.Create(Result);
  296.     with SP do begin
  297.       Parent:= MP;
  298.       Left:= 185;
  299.       Top := 8;
  300.       Width := 25;
  301.       Height := 25;
  302.       Hint := 'L÷schen';
  303.       Name := 'LoeschBttn';
  304.       Glyph.Handle:= LoadBitmap(HInstance,'LOESCHEN');
  305.       Method.Code := TProxyForm(Result).CreateMethod('LoeschBttnClick');
  306.       Method.Data := Result;
  307.       Sp.OnClick := TNotifyEvent(Method);
  308.     end;
  309.  
  310.     Sp:= TSpeedButton.Create(Result);
  311.     with SP do begin
  312.       Parent:= MP;
  313.       Left:= 215;
  314.       Top := 8;
  315.       Width := 25;
  316.       Height := 25;
  317.       Hint := 'Ok';
  318.       Name := 'OkBttn';
  319.       Glyph.Handle:= LoadBitmap(HInstance,'OK');
  320.       Method.Code := TProxyForm(Result).CreateMethod('OkBttnClick');
  321.       Method.Data := Result;
  322.       Sp.OnClick := TNotifyEvent(Method);
  323.     end;
  324.  
  325.     Sp:= TSpeedButton.Create(Result);
  326.     with SP do begin
  327.       Parent:= MP;
  328.       Left:= 358;
  329.       Top := 8;
  330.       Width := 25;
  331.       Height := 25;
  332.       Hint := 'Ende';
  333.       Name := 'AbbruchBttn';
  334.       Glyph.Handle:= LoadBitmap(HInstance,'ENDE');
  335.       Method.Code := TProxyForm(Result).CreateMethod('AbbruchBttnClick');
  336.       Method.Data := Result;
  337.       Sp.OnClick := TNotifyEvent(Method);
  338.     end;
  339.  
  340.     UP:= TPanel.Create(Result);
  341.     with UP do begin
  342.       Parent := Result;
  343.       Name := 'Panel2';
  344.       Align := alBottom;
  345.       BevelInner:= bvLowered;
  346.       Height:= 27;
  347.       ShowHint:= False;
  348.       Caption:= '';
  349.     end;
  350.  
  351.     UP1:= TPanel.Create(Result);
  352.     With UP1 do begin
  353.       Parent:= UP;
  354.       Left  := 308;
  355.       Top   := 2;
  356.       Width := 108;
  357.       Height:= 23;
  358.       Align := alRight;
  359.       BevelOuter := bvLowered;
  360.       Font.Color := clBlack;
  361.       Font.Height := -11;
  362.       Font.Name := 'Arial';
  363.       Font.Style := [];
  364.       Name:= 'ZeitPanel';
  365.       Caption:= '';
  366.     end;
  367.  
  368.     UP3:= TPanel.Create(Result);
  369.     with UP3 do begin
  370.       Parent:= UP;
  371.       Left  := 2;
  372.       Top   := 2;
  373.       Width := 186;
  374.       Height:= 23;
  375.       Align := alClient;
  376.       ShowHint:= True;
  377.       BevelInner := bvLowered;
  378.       BevelOuter := bvNone;
  379.       Font.Color := clBlack;
  380.       Font.Height := -11;
  381.       Font.Name   := 'Arial';
  382.       Font.Style  := [];
  383.       Name:= 'HintPanel';
  384.       Caption:= '';
  385.     end;
  386.  
  387.     Tm:= TTimer.Create(Result);
  388.     With Tm do begin
  389.       Interval:= 1000;
  390.       Name:= FormIdent+'Timer';
  391.       Method.Code := TProxyForm(Result).CreateMethod(FormIdent+'TimerTimer');
  392.       Method.Data := Result;
  393.       Tm.OnTimer := TNotifyEvent(Method);
  394.     end;
  395.  
  396.     Tbl:= TIsamTable.Create(Result);
  397.     with Tbl do begin
  398.       Name:= FormIdent+'TABLE';
  399.       TableName   := '';
  400.     end;
  401.  
  402.     if SrcTable.IsamRecord.Count > 0 then begin
  403.       Ty:= 52;
  404.       For i:= 0 to SrcTable.IsamRecord.Count - 1 do begin
  405.         SStr:= SrcTable.IsamRecord[i];
  406.         if (Pos(':',SStr) > 0) and (Pos('DUMMY',UpperCase(SStr)) = 0) then begin
  407.           G:= GetFieldTypEditor(SStr,FieldName,FieldDataType,Len);
  408.           if Label_Neben_Input = False then Inc(Ty,18);
  409.           if InputLen_Fest then W:= 130 else W:= 8 * (Len - 1);
  410.           if W < 30 then W:= 30;
  411.           {$IFDEF SHAREWARE}
  412.           Case G of
  413.             1: begin
  414.                  PInp:= TOvcPictureField.Create(Result);
  415.                  with PInp do begin
  416.                    Name:= FieldName + 'Input';
  417.                    Parent:= Result;
  418.                    if Label_Neben_Input then Left:= 100 else Left:= 20;
  419.                    Top   := Ty;
  420.                    Width := W;
  421.                    Height := 21;
  422.                    Cursor := crIBeam;
  423.                    HighlightColors.BackColor := clHighlight;
  424.                    HighlightColors.TextColor := clHighlightText;
  425.                    HighlightColors.UseDefault := False;
  426.                    Font.Color := EFont.Color;
  427.                    Font.Height := EFont.Height;
  428.                    Font.Name := EFont.Name;
  429.                    Font.Style := EFont.Style;
  430.                    ParentColor := False;
  431.                    TabStop := True;
  432.                    if FieldDataType = ftTime then begin
  433.                      DataType := pftTime;
  434.                      MaxLength:= 5;
  435.                      PictureMask:= 'hh:mm';
  436.                      RangeHi:= '23:59';
  437.                      RangeLo:= '00:00';
  438.                    end
  439.                    else begin
  440.                      DataType:= pftDate;
  441.                      MaxLength:= 10;
  442.                      PictureMask := 'dd/mm/yyyy';
  443.                    end;
  444.                  end;
  445.                end;
  446.             2: begin
  447.                  SInp:= TOvcSimpleField.Create(Result);
  448.                  with SInp do begin
  449.                    Name:= FieldName + 'Input';
  450.                    Parent:= Result;
  451.                    if Label_Neben_Input then Left:= 100 else Left:= 20;
  452.                    Top   := Ty;
  453.                    Width := W;
  454.                    Height := 21;
  455.                    Cursor := crIBeam;
  456.                    HighlightColors.BackColor := clHighlight;
  457.                    HighlightColors.TextColor := clHighlightText;
  458.                    HighlightColors.UseDefault := False;
  459.                    Font.Color := EFont.Color;
  460.                    Font.Height := EFont.Height;
  461.                    Font.Name := EFont.Name;
  462.                    Font.Style := EFont.Style;
  463.                    ParentColor := False;
  464.                    TabStop := True;
  465.                    Case FieldDataType of
  466.                      ftInteger : DataType:= sftLongint;
  467.                      ftSmallInt: DataType:= sftShortInt;
  468.                      ftWord    : DataType:= sftWord;
  469.                      else begin
  470.                        DataType:= sftReal;
  471.                        DecimalPlaces:= 2;
  472.                      end;
  473.                    end;
  474.                  end;
  475.                end;
  476.             3: begin
  477.                  MInp:= TMemo.Create(Result);
  478.                  with MInp do begin
  479.                    Name:= FieldName + 'Input';
  480.                    Parent:= Result;
  481.                    if Label_Neben_Input then Left:= 100 else Left:= 20;
  482.                    Top   := Ty;
  483.                    Width := 130;
  484.                    Height := 89;
  485.                    Font.Color := EFont.Color;
  486.                    Font.Height := EFont.Height;
  487.                    Font.Name := Efont.Name;
  488.                    Font.Style := EFont.Style;
  489.                    ParentColor := False;
  490.                    TabStop := True;
  491.                  end;
  492.                end;
  493.             else begin
  494.                  SInp:= TOvcSimpleField.Create(Result);
  495.                  with SInp do begin
  496.                    Name:= FieldName + 'Input';
  497.                    Parent:= Result;
  498.                    if Label_Neben_Input then Left:= 100 else Left:= 20;
  499.                    Top   := Ty;
  500.                    Width := W;
  501.                    Height := 21;
  502.                    Cursor := crIBeam;
  503.                    HighlightColors.BackColor := clHighlight;
  504.                    HighlightColors.TextColor := clHighlightText;
  505.                    HighlightColors.UseDefault := False;
  506.                    Font.Color := EFont.Color;
  507.                    Font.Height := EFont.Height;
  508.                    Font.Name := EFont.Name;
  509.                    Font.Style := EFont.Style;
  510.                    ParentColor := False;
  511.                    TabStop := True;
  512.                    DataType := sftString;
  513.                    MaxLength := Len;
  514.                    PictureMask := 'X';
  515.                  end;
  516.                end;
  517.           end;
  518.           {$ELSE}
  519.           Case G of
  520.             1: begin
  521.                  PInp:= TEdit.Create(Result);
  522.                  with PInp do begin
  523.                    Name:= FieldName + 'Input';
  524.                    Parent:= Result;
  525.                    if Label_Neben_Input then Left:= 100 else Left:= 20;
  526.                    Top   := Ty;
  527.                    Width := W;
  528.                    Height := 21;
  529.                    Cursor := crIBeam;
  530.                    Font.Color := EFont.Color;
  531.                    Font.Height := EFont.Height;
  532.                    Font.Name := EFont.Name;
  533.                    Font.Style := EFont.Style;
  534.                    ParentColor := False;
  535.                    TabStop := True;
  536.                    if FieldDataType = ftTime then begin
  537.                      MaxLength:= 5;
  538.                    end
  539.                    else begin
  540.                      MaxLength:= 10;
  541.                    end;
  542.                  end;
  543.                end;
  544.             2: begin
  545.                  SInp:= TEdit.Create(Result);
  546.                  with SInp do begin
  547.                    Name:= FieldName + 'Input';
  548.                    Parent:= Result;
  549.                    if Label_Neben_Input then Left:= 100 else Left:= 20;
  550.                    Top   := Ty;
  551.                    Width := W;
  552.                    Height := 21;
  553.                    Cursor := crIBeam;
  554.                    Font.Color := EFont.Color;
  555.                    Font.Height := EFont.Height;
  556.                    Font.Name := EFont.Name;
  557.                    Font.Style := EFont.Style;
  558.                    ParentColor := False;
  559.                    TabStop := True;
  560.                  end;
  561.                end;
  562.             3: begin
  563.                  MInp:= TMemo.Create(Result);
  564.                  with MInp do begin
  565.                    Name:= FieldName + 'Input';
  566.                    Parent:= Result;
  567.                    if Label_Neben_Input then Left:= 100 else Left:= 20;
  568.                    Top   := Ty;
  569.                    Width := 130;
  570.                    Height := 89;
  571.                    Font.Color := EFont.Color;
  572.                    Font.Height := EFont.Height;
  573.                    Font.Name := Efont.Name;
  574.                    Font.Style := EFont.Style;
  575.                    ParentColor := False;
  576.                    TabStop := True;
  577.                  end;
  578.                end;
  579.             else begin
  580.                  SInp:= TEdit.Create(Result);
  581.                  with SInp do begin
  582.                    Name:= FieldName + 'Input';
  583.                    Parent:= Result;
  584.                    if Label_Neben_Input then Left:= 100 else Left:= 20;
  585.                    Top   := Ty;
  586.                    Width := W;
  587.                    Height := 21;
  588.                    Cursor := crIBeam;
  589.                    Font.Color := EFont.Color;
  590.                    Font.Height := EFont.Height;
  591.                    Font.Name := EFont.Name;
  592.                    Font.Style := EFont.Style;
  593.                    ParentColor := False;
  594.                    TabStop := True;
  595.                    MaxLength:= Len;
  596.                  end;
  597.                end;
  598.            end;
  599.           {$ENDIF}   
  600.           if Label_Neben_Input = False then Dec(Ty,18);
  601.           SLab:= TLabel.Create(Result);
  602.           With SLab do begin
  603.             Name:= FieldName+'Label';
  604.             Parent:= Result;
  605.             Caption:= FieldName;
  606.             Left:= 20;
  607.             Top:= Ty + 2;
  608.             Font.Color := LFont.Color;
  609.             Font.Height := LFont.Height;
  610.             Font.Name := LFont.Name;
  611.             Font.Style := LFont.Style;
  612.           end;
  613.           Ty:= Ty+24;
  614.           if Label_Neben_Input = False then Inc(Ty,20);
  615.           if G = 3 then Ty:= Ty + 68;
  616.         end;
  617.       end;
  618.     end;
  619.   end;
  620. end;
  621.  
  622. function Erzeuge_EditorSource(const UnitIdent, FormIdent: string;
  623.                               SrcTable: TIsamTable): TMemoryStream;
  624. const
  625.   CRLF = #13#10;
  626. Var I,Len: integer;
  627.     G: Byte;
  628.     FieldDataType: TFieldType;
  629.     FieldName,NStr,SStr : String;
  630. begin
  631.   SourceBuffer := StrAlloc(SourceBufferSize);
  632.   try
  633.     Result := TMemoryStream.Create;
  634.     try
  635.  
  636.       { unit header and uses clause }
  637.       FmtWrite(Result,
  638.         'unit %s;' + CRLF + CRLF +
  639.         'interface' + CRLF + CRLF +
  640.         'uses'#13#10 +
  641.         '  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,'#13#10 +
  642.         '  StdCtrls, ExtCtrls, Forms', [UnitIdent]);
  643.  
  644.       FmtWrite(Result,
  645.         ',Inp_Tool, Buttons,'+CRLF,[NIL]);
  646.  
  647.       {$IFDEF SHAREWARE}
  648.       if NormInputs then begin
  649.         FmtWrite(Result,
  650.           'OvcPb, OvcNf, OvcBase, OvcEf, OvcSf, OvcPf,'+CRLF,[NIL]);
  651.       end;
  652.       {$ENDIF}
  653.       FmtWrite(Result,
  654.       ' IsamTabl;' + CRLF + CRLF, [nil]);
  655.  
  656.       { begin the class declaration }
  657.       if SrcTable.IsamRecord.Count > 0 then begin
  658.         For i:= 0 to SrcTable.IsamRecord.Count - 1 do begin
  659.           FmtWrite(Result,'  %s'+CRLF,[SrcTable.IsamRecord[i]]);
  660.         end;
  661.       end;
  662.       FmtWrite(Result,
  663.         'type'#13#10 +
  664.         '  T%s = class(TForm)'#13#10, [FormIdent]);
  665.  
  666.       FmtWrite(Result,
  667.         '    Panel1 : TPanel;'  + CRLF +
  668.         '    Panel2 : TPanel;'  + CRLF +
  669.         '    ZeitPanel: TPanel;'+ CRLF +
  670.         '    HintPanel: TPanel;'+ CRLF +
  671.         '    %sTimer  : TTimer;'+ CRLF,[FormIdent]);
  672.       FmtWrite(Result,
  673.         '    RueckBttn: TSpeedButton;' + CRLF +
  674.         '    VorBttn: TSpeedButton;'   + CRLF +
  675.         '    SuchBttn: TSpeedButton;'  + CRLF +
  676.         '    KeyBttn: TSpeedButton;'   + CRLF +
  677.         '    NeuBttn: TSpeedButton;'   + CRLF,[NIL]);
  678.  
  679.       FmtWrite(Result,
  680.         '    AnlegBttn: TSpeedButton;' + CRLF +
  681.         '    AendernBttn: TSpeedButton;' + CRLF,[NIL]);
  682.  
  683.       FmtWrite(Result,
  684.         '    LoeschBttn: TSpeedButton;'  + CRLF +
  685.         '    OkBttn: TSpeedButton;'      + CRLF +
  686.         '    AbbruchBttn: TSpeedButton;' + CRLF, [NIL]);
  687.  
  688.       FmtWrite(Result,
  689.         '    %sTable: TIsamTable;'+CRLF,[FormIdent]);
  690.  
  691.       {$IFDEF SHAREWARE}
  692.       if Norminputs then
  693.         FmtWrite(Result,'    DefaultController: TOvcController;'+CRLF,[NIL]);
  694.       {$ENDIF}
  695.  
  696.       if SrcTable.IsamRecord.Count > 0 then begin
  697.         For i:= 0 to SrcTable.IsamRecord.Count-1 do begin
  698.           SStr:= SrcTable.IsamRecord[i];
  699.           if (Pos(':',SStr) > 0) and (Pos('DUMMY',UpperCase(SStr)) = 0) then begin
  700.             G:= GetFieldTypEditor(SStr,FieldName,FieldDataType,Len);
  701.             {$IFDEF SHAREWARE}
  702.             Case G of
  703.               1: FmtWrite(Result,
  704.                     '    %sInput: TOvcPictureField;'+CRLF+
  705.                     '    %sLabel: TLabel;'+CRLF,[F.FieldName,F.FieldName]);
  706.               2: FmtWrite(Result,
  707.                     '    %sInput: TOvcSimpleField;'+CRLF+
  708.                     '    %sLabel: TLabel;'+CRLF,[F.FieldName,F.FieldName]);
  709.               3: FmtWrite(Result,
  710.                     '    %sInput: TMemo;'+CRLF+
  711.                     '    %sLabel: TLabel;'+CRLF,[F.FieldName,F.FieldName]);
  712.               else FmtWrite(Result,
  713.                     '    %sInput: TOvcSimpleField;'+CRLF+
  714.                     '    %sLabel: TLabel;'+CRLF,[F.FieldName,F.FieldName]);
  715.             end;
  716.             {$ELSE}
  717.             Case G of
  718.               1: FmtWrite(Result,
  719.                     '    %sInput: TEdit;'+CRLF+
  720.                     '    %sLabel: TLabel;'+CRLF,[FieldName,FieldName]);
  721.               2: FmtWrite(Result,
  722.                     '    %sInput: TEdit;'+CRLF+
  723.                     '    %sLabel: TLabel;'+CRLF,[FieldName,FieldName]);
  724.               3: FmtWrite(Result,
  725.                     '    %sInput: TMemo;'+CRLF+
  726.                     '    %sLabel: TLabel;'+CRLF,[FieldName,FieldName]);
  727.               else FmtWrite(Result,
  728.                     '    %sInput: TEdit;'+CRLF+
  729.                     '    %sLabel: TLabel;'+CRLF,[FieldName,FieldName]);
  730.             end;
  731.             {$ENDIF}
  732.           end;
  733.         end;
  734.       end;
  735.  
  736.       FmtWrite(Result,
  737.         '    procedure FormCreate(Sender: TObject);' + CRLF +
  738.         '    procedure VorBttnClick(Sender: TObject);'     + CRLF +
  739.         '    procedure RueckBttnClick(Sender: TObject);'   + CRLF +
  740.         '    procedure NeuBttnClick(Sender: TObject);'     + CRLF +
  741.         '    procedure OkBttnClick(Sender: TObject);'      + CRLF,[NIL]);
  742.       FmtWrite(Result,
  743.         '    procedure AbbruchBttnClick(Sender: TObject);' + CRLF,[NIL]);
  744.       FmtWrite(Result,
  745.         '    procedure AendernBttnClick(Sender: TObject);' + CRLF +
  746.         '    procedure AnlegBttnClick(Sender: TObject);'   + CRLF,[NIL]);
  747.       FmtWrite(Result,
  748.         '    procedure LoeschBttnClick(Sender: TObject);'  + CRLF +
  749.         '    procedure SuchBttnClick(Sender: TObject);'    + CRLF +
  750.         '    procedure KeyBttnClick(Sender: TObject);'     + CRLF, [NIL]);
  751.  
  752.       FmtWrite(Result,
  753.         '    Procedure ShowHint(Sender: TObject);    ' + CRLF +
  754.         '    Procedure %sTimerTimer(Sender: TObject);'  + CRLF +
  755.         '  private'+CRLF,[FormIdent]);
  756.  
  757.       FmtWrite(Result,
  758.         '    Function IsModified: Boolean;' + CRLF +
  759.         '    Procedure ResetModified;'      + CRLF,[NIL]);
  760.       FmtWrite(Result,
  761.         '  public'                          + CRLF,[NIL]);
  762.       FmtWrite(Result,
  763.         '    Procedure SetData;'            + CRLF +
  764.         '    Procedure LeerData;'           + CRLF +
  765.         '    Procedure GetData;'            + CRLF,
  766.         [nil]);
  767.       FmtWrite(Result,
  768.         '  end;' + CRLF + CRLF +
  769.         'var' + CRLF +
  770.         '  %s: T%s;' + CRLF + CRLF,[FormIdent, FormIdent]);
  771.  
  772.       FmtWrite(Result,
  773.         '  %sData,%sDup: %s;' + CRLF + CRLF,[SrcTable.RecordName,SrcTable.RecordName,SrcTable.RecordName]);
  774.  
  775.       FmtWrite(Result,
  776.         'implementation' + CRLF + CRLF +
  777.         'Uses UToolDll, UBrwTool, Isam_Key;' + CRLF + CRLF +
  778.         '{$R *.DFM}' + CRLF + CRLF, [NIL]);
  779.  
  780.       FmtWrite(Result,
  781.         'procedure T%s.FormCreate(Sender: TObject);' + CRLF +
  782.         'begin'                                      + CRLF +
  783.         '  Application.OnHint:= ShowHint;'           + CRLF,[FormIdent]);
  784.       FmtWrite(Result,
  785.         'end;' + CRLF + CRLF,[NIL]);
  786.  
  787.       FmtWrite(Result,
  788.           'Function T%s.IsModified: Boolean;' + CRLF +
  789.           'var M: Boolean;'       + CRLF +
  790.           '    i: Integer;'       + CRLF +
  791.           'begin'                 + CRLF +
  792.           '  M:= False;'          + CRLF +
  793.           '  if ComponentCount > 0 then begin' + CRLF +
  794.           '    i:= 0;'                         + CRLF,[FormIdent]);
  795.  
  796.       FmtWrite(Result,
  797.           '    Repeat'                         + CRLF +
  798.           '      if Components[i] is TEdit then begin' + CRLF +
  799.           '        if TEdit(Components[i]).Modified then M:= True;'+ CRLF +
  800.           '      end'                                              + CRLF +
  801.           '      else if Components[i] is TMemo then begin'        + CRLF +
  802.           '        if TMemo(Components[i]).Modified then M:= True;'+ CRLF +
  803.           '      end'                                              + CRLF,[NIL]);
  804.  
  805.       FmtWrite(Result,
  806.           '      else if (Components[i] is TInput) then begin'     + CRLF +
  807.           '        if TInput(Components[i]).Modified then M:= True;'+ CRLF,[NIL]);
  808.  
  809.      {$IFDEF SHAREWARE}
  810.       FmtWrite(Result,
  811.             '      end'+CRLF+
  812.             '      else if (Components[i] is TOvcPictureField) then begin' + CRLF +
  813.             '        if TOvcPictureField(Components[i]).Modified then M:= True;'+ CRLF +
  814.             '      end'+CRLF,[NIL]);
  815.  
  816.       FmtWrite(Result,
  817.             '      else if (Components[i] is TOvcSimpleField) then begin' + CRLF +
  818.             '        if TOvcSimpleField(Components[i]).Modified then M:= True;' + CRLF +
  819.             '      end'                                                         + CRLF,[NIL]);
  820.  
  821.       FmtWrite(Result,
  822.             '      else if (Components[i] is TOvcNumericField) then begin' + CRLF +
  823.             '        if TOvcNumericField(Components[i]).Modified then M:= True;' + CRLF +
  824.             '      end;'                                                         + CRLF,[NIL]);
  825.       {$ELSE}
  826.       FmtWrite(Result,
  827.             '      end;'+CRLF,[NIL]);
  828.       {$ENDIF}
  829.       FmtWrite(Result,
  830.           '      inc(i);'                                           + CRLF +
  831.           '    Until (i >= ComponentCount) or (M = True);'          + CRLF +
  832.           '  end;'                                                  + CRLF +
  833.           '  IsModified:= M;'                                       + CRLF +
  834.           'end;' + CRLF + CRLF, [NIL]);
  835.  
  836.       FmtWrite(Result,
  837.             'procedure T%s.ResetModified;' + CRLF +
  838.             'var i: Integer;'              + CRLF +
  839.             'begin'                        + CRLF +
  840.             '  if ComponentCount > 0 then begin' + CRLF +
  841.             '    i:= 0;'                       + CRLF, [FormIdent]);
  842.  
  843.       FmtWrite(Result,
  844.             '    Repeat'                       + CRLF +
  845.             '      if Components[i] is TEdit then begin' + CRLF +
  846.             '        TEdit(Components[i]).Modified:= False;' + CRLF +
  847.             '      end'                                      + CRLF,[NIL]);
  848.       FmtWrite(Result,
  849.             '      else if Components[i] is TMemo then begin' + CRLF +
  850.             '        TMemo(Components[i]).Modified:= False;'  + CRLF +
  851.             '      end'                                       + CRLF, [NIL]);
  852.  
  853.       FmtWrite(Result,
  854.             '      else if (Components[i] is TInput) then begin' + CRLF +
  855.             '        TInput(Components[i]).Modified:= False;'    + CRLF,[NIL]);
  856.  
  857.       {$IFDEF SHAREWARE}
  858.       FmtWrite(Result,
  859.             '      end'+CRLF+
  860.             '      else if (Components[i] is TOvcPictureField) then begin' + CRLF +
  861.             '        TOvcPictureField(Components[i]).Modified:= False;'+ CRLF +
  862.             '      end'+CRLF,[NIL]);
  863.  
  864.       FmtWrite(Result,
  865.             '      else if (Components[i] is TOvcSimpleField) then begin' + CRLF +
  866.             '        TOvcSimpleField(Components[i]).Modified:= False;' + CRLF +
  867.             '      end'                                                   + CRLF,[NIL]);
  868.  
  869.       FmtWrite(Result,
  870.             '      else if (Components[i] is TOvcNumericField) then begin'+ CRLF +
  871.             '        TOvcNumericField(Components[i]).Modified:= False;'+ CRLF +
  872.             '      end;' + CRLF,[NIL]);
  873.       {$ELSE}
  874.       FmtWrite(Result,
  875.             '      end;' + CRLF,[NIL]);
  876.       {$ENDIF}
  877.  
  878.       FmtWrite(Result,
  879.             '      inc(i);'                                      + CRLF +
  880.             '    Until (i >= ComponentCount);'                     + CRLF +
  881.             '  end;'                                             + CRLF +
  882.             'end;' + CRLF + CRLF, [NIL]);
  883.  
  884.       FmtWrite(Result,
  885.           'Procedure T%s.SetData;' + CRLF +
  886.           'begin'                            + CRLF+
  887.           '  Fillchar(%sData,Sizeof(%sData),0);'+CRLF+
  888.           '  %sTable.Get(%sData,%sDup);'+CRLF,[FormIdent,
  889.                SrcTable.RecordName,SrcTable.RecordName,FormIdent,SrcTable.RecordName,SrcTable.RecordName]);
  890.  
  891.       {$IFDEF SHAREWARE}
  892.       if SrcTable.IsamRecord.Count > 0 then begin
  893.         FmtWrite(Result,'  with %sData do begin'+CRLF,[SrcTable.Recordname]);
  894.         For i:= 0 to SrcTable.IsamRecord.Count-1 do begin
  895.           SStr:= SrcTable.IsamRecord[i];
  896.           if (Pos(':',SStr) > 0) and (Pos('DUMMY',UpperCase(SStr)) = 0) then begin
  897.             G:= GetFieldTypEditor(SStr,FieldName,FieldDataType,Len);
  898.             case FieldDataType of
  899.               ftSmallInt: FmtWrite(Result,
  900.                      '    %sInput.AsInteger:= %s;'+CRLF,[FieldName,FieldName]);
  901.               ftInteger : FmtWrite(Result,
  902.                      '    %sInput.AsLongint:= %s;'+CRLF,[FieldName,FieldName]);
  903.               ftWord    : FmtWrite(Result,
  904.                      '    %sInput.AsLongint:= %s;'+CRLF,[FieldName,FieldName]);
  905.               ftFloat   : FmtWrite(Result,
  906.                      '    %sInput.AsFloat:= %s;'+CRLF,[FieldName,FieldName]);
  907.               ftMemo    : FmtWrite(Result,
  908.                      '    %sInput.Assign(%s;'+CRLF,[FieldName,FieldName]);
  909.               else FmtWrite(Result,
  910.                      '    %sInput.AsString:= %s;'+CRLF,[FieldName,FieldName]);
  911.             end;
  912.           end;
  913.         end;
  914.         FmtWrite(Result,'  end;'+CRLF,[NIL]);
  915.       end;
  916.       {$ELSE}
  917.       if SrcTable.IsamRecord.Count > 0 then begin
  918.         FmtWrite(Result,'  with %sData do begin'+CRLF,[SrcTable.Recordname]);
  919.         For i:= 0 to SrcTable.IsamRecord.Count-1 do begin
  920.           SStr:= SrcTable.IsamRecord[i];
  921.           if (Pos(':',SStr) > 0) and (Pos('DUMMY',UpperCase(SStr)) = 0) then begin
  922.             G:= GetFieldTypEditor(SStr,FieldName,FieldDataType,Len);
  923.             case FieldDataType of
  924.               ftSmallInt: FmtWrite(Result,
  925.                      '    %sInput.Text:= DezStr(%s);'+CRLF,[FieldName,FieldName]);
  926.               ftInteger : FmtWrite(Result,
  927.                      '    %sInput.Text:= DezStr(%s);'+CRLF,[FieldName,FieldName]);
  928.               ftWord    : FmtWrite(Result,
  929.                      '    %sInput.Text:= DezStr(%s);'+CRLF,[FieldName,FieldName]);
  930.               ftFloat   : FmtWrite(Result,
  931.                      '    %sInput.Text:= DezStr(%s);'+CRLF,[FieldName,FieldName]);
  932.               ftMemo    : FmtWrite(Result,
  933.                      '    %sInput.Assign(%s);'+CRLF,[FieldName,FieldName]);
  934.               else FmtWrite(Result,
  935.                      '    %sInput.Text:= %s;'+CRLF,[FieldName,FieldName]);
  936.             end;
  937.           end;
  938.         end;
  939.         FmtWrite(Result,'  end;'+CRLF,[NIL]);
  940.       end;
  941.       {$ENDIF}
  942.       FmtWrite(Result,
  943.           '  {AnlegBttn.Enabled:= False;}'     + CRLF +
  944.           '  {AendernBttn.Enabled:= True;}'    + CRLF +
  945.           '  {LoeschBttn.Enabled:= True;}'       + CRLF +
  946.           '  ResetModified;'                   + CRLF +
  947.           'end;'+ CRLF + CRLF, [NIL]);
  948.  
  949.       FmtWrite(Result,
  950.           'Procedure T%s.GetData;' + CRLF +
  951.           'var Code: Integer;'+ CRLF+
  952.           'begin'                  + CRLF,[FormIdent]);
  953.  
  954.       {$IFDEF SHAREWARE}
  955.       if SrcTable.IsamRecord.Count > 0 then begin
  956.         FmtWrite(Result,'  Fillchar(%sData,Sizeof(%sData),0);'+CRLF,[SrcTable.RecordName,SrcTable.RecordName]);
  957.         FmtWrite(Result,'  with %sData do begin'+CRLF,[SrcTable.Recordname]);
  958.         For i:= 0 to SrcTable.IsamRecord.Count-1 do begin
  959.           SStr:= SrcTable.IsamRecord[i];
  960.           if (Pos(':',SStr) > 0) and (Pos('DUMMY',UpperCase(SStr)) = 0) then begin
  961.             G:= GetFieldTypEditor(SStr,FieldName,FieldDataType,Len);
  962.             Case FieldDataType of
  963.               ftSmallInt: FmtWrite(Result,
  964.                             '    %s:= %sInput.AsInteger;'+CRLF,[FieldName,FieldName]);
  965.               ftInteger : FmtWrite(Result,
  966.                             '    %s:= %sInput.AsLongint;'+CRLF,[FieldName,FieldName]);
  967.               ftWord    : FmtWrite(Result,
  968.                             '    %s:= %sInput.AsInteger;'+CRLF,[FieldName,FieldName]);
  969.               ftFloat   : FmtWrite(Result,
  970.                             '    %s:= %sInput.AsFloat;'+CRLF,[FieldName,FieldName]);
  971.               ftMemo    : FmtWrite(Result,
  972.                             '    %s.Assign(%sInput.Strings);' + CRLF,[FieldName,FieldName]);
  973.               else         FmtWrite(Result,
  974.                             '    %s:= %sInput.AsString;'+CRLF,[FieldName,FieldName]);
  975.             end;
  976.           end;
  977.         end;
  978.         FmtWrite(Result,'  end;'+CRLF,[NIL]);
  979.       end;
  980.       {$ELSE}
  981.       if SrcTable.IsamRecord.Count > 0 then begin
  982.         FmtWrite(Result,'  Fillchar(%sData,Sizeof(%sData),0);'+CRLF,[SrcTable.RecordName,SrcTable.RecordName]);
  983.         FmtWrite(Result,'  with %sData do begin'+CRLF,[SrcTable.Recordname]);
  984.         For i:= 0 to SrcTable.IsamRecord.Count-1 do begin
  985.           SStr:= SrcTable.IsamRecord[i];
  986.           if (Pos(':',SStr) > 0) and (Pos('DUMMY',UpperCase(SStr)) = 0) then begin
  987.             G:= GetFieldTypEditor(SStr,FieldName,FieldDataType,Len);
  988.             Case FieldDataType of
  989.               ftSmallInt: FmtWrite(Result,
  990.                             '    Val(%sInput.Text,%s,Code);'+CRLF,[FieldName,FieldName]);
  991.               ftInteger : FmtWrite(Result,
  992.                             '    Val(%sInput.Text,%s,Code);'+CRLF,[FieldName,FieldName]);
  993.               ftWord    : FmtWrite(Result,
  994.                             '    Val(%sInput.Text,%s,Code);'+CRLF,[FieldName,FieldName]);
  995.               ftFloat   : FmtWrite(Result,
  996.                             '    Val(%sInput.Text,%s,Code);'+CRLF,[FieldName,FieldName]);
  997.               ftMemo    : FmtWrite(Result,
  998.                             '    %s.Assign(%sInput.Strings);' + CRLF,[FieldName,FieldName]);
  999.               else         FmtWrite(Result,
  1000.                             '    %s:= %sInput.Text;'+CRLF,[FieldName,FieldName]);
  1001.             end;
  1002.           end;
  1003.         end;
  1004.         FmtWrite(Result,'  end;'+CRLF,[NIL]);
  1005.       end;
  1006.       {$ENDIF}
  1007.       FmtWrite(Result,
  1008.           'end;' + CRLF + CRLF, [NIL]);
  1009.  
  1010.       FmtWrite(Result,
  1011.           'Procedure T%s.LeerData;' + CRLF +
  1012.           'begin'                   + CRLF,[FormIdent]);
  1013.  
  1014.       {$IFDEF SHAREWARE}
  1015.       if SrcTable.IsamRecord.Count > 0 then begin
  1016.         For i:= 0 to SrcTable.IsamRecord.Count-1 do begin
  1017.           SStr:= SrcTable.IsamRecord[i];
  1018.           if (Pos(':',SStr) > 0) and (Pos('DUMMY',UpperCase(SStr)) = 0) then begin
  1019.             G:= GetFieldTypEditor(SStr,FieldName,FieldDataType,Len);
  1020.             Case FieldDataType of
  1021.               ftSmallInt: FmtWrite(Result,
  1022.                             '  %sInput.AsInteger:= 0;'+ CRLF,[F.FieldName]);
  1023.               ftInteger : FmtWrite(Result,
  1024.                             '  %sInput.AsLongint:= 0;'+ CRLF,[F.FieldName]);
  1025.               ftFloat   : FmtWrite(Result,
  1026.                             '  %sInput.AsFloat:= 0;'+ CRLF,[F.FieldName]);
  1027.               ftMemo    : FmtWrite(Result,
  1028.                             '  %sInput.Strings.Clear;'+ CRLF,[F.FieldName]);
  1029.               else FmtWrite(Result,
  1030.                        '  %sInput.AsString:= '+Chr(39)+ Chr(39)+';'+CRLF,[F.FieldName]);
  1031.             end;
  1032.       {$ELSE}
  1033.       if SrcTable.IsamRecord.Count > 0 then begin
  1034.         For i:= 0 to SrcTable.IsamRecord.Count-1 do begin
  1035.           SStr:= SrcTable.IsamRecord[i];
  1036.           if (Pos(':',SStr) > 0) and (Pos('DUMMY',UpperCase(SStr)) = 0) then begin
  1037.             G:= GetFieldTypEditor(SStr,FieldName,FieldDataType,Len);
  1038.             Case FieldDataType of
  1039.               ftSmallInt: FmtWrite(Result,
  1040.                             '  %sInput.Text:= '+Chr(39)+'0'+Chr(39)+';'+ CRLF,[FieldName]);
  1041.               ftInteger : FmtWrite(Result,
  1042.                             '  %sInput.Text:= '+Chr(39)+'0'+Chr(39)+';'+ CRLF,[FieldName]);
  1043.               ftFloat   : FmtWrite(Result,
  1044.                             '  %sInput.Text:= '+Chr(39)+'0.00'+Chr(39)+';'+ CRLF,[FieldName]);
  1045.               ftMemo    : FmtWrite(Result,
  1046.                             '  %sInput.Strings.Clear;'+ CRLF,[FieldName]);
  1047.               else FmtWrite(Result,
  1048.                      '  %sInput.Text:= '+Chr(39)+ Chr(39)+';'+CRLF,[FieldName]);
  1049.             end;
  1050.           end;
  1051.         end;
  1052.       end;
  1053.       {$ENDIF}
  1054.       FmtWrite(Result,
  1055.           '  {AnlegBttn.Enabled:= True;}' + CRLF +
  1056.           '  {AendernBttn.Enabled:= False;}' + CRLF +
  1057.           '  {LoeschBttn.Enabled:= False;}' + CRLF  +
  1058.           'end;'                    + CRLF + CRLF, [NIL]);
  1059.  
  1060.       FmtWrite(Result,
  1061.           'procedure T%s.VorBttnClick(Sender: TObject);' + CRLF +
  1062.           'begin'                                        + CRLF,[FormIdent]);
  1063.  
  1064.       FmtWrite(Result,
  1065.         '  if (IsModified) then begin'                 + CRLF +
  1066.         '    if JaNein('+Chr(39)+'Daten wurden nicht gespeichert'+Chr(39)+','+Chr(39)+'Trotzdem weiter ?'+Chr(39)+
  1067.                  ') = False then Exit;' + CRLF +
  1068.         '  end;'                                       + CRLF +
  1069.         '  %sTable.Next(%sData,%sDup);'                + CRLF +
  1070.         '  SetData;'                                   + CRLF +
  1071.         'end;'  + CRLF + CRLF, [FormIdent,SrcTable.RecordName,SrcTable.RecordName]);
  1072.  
  1073.       FmtWrite(Result,
  1074.           'procedure T%s.RueckBttnClick(Sender: TObject);' + CRLF +
  1075.           'begin'                                          + CRLF,[FormIdent]);
  1076.  
  1077.       FmtWrite(Result,
  1078.         '  if (IsModified) then begin'                   + CRLF +
  1079.         '    if JaNein('+Chr(39)+'Daten wurden nicht gespeichert'+Chr(39)+','+Chr(39)+'Trotzdem weiter ?'+Chr(39)+
  1080.                  ') = False then Exit;' + CRLF +
  1081.         '  end;'                                         + CRLF +
  1082.         '  %sTable.Prior(%sData,%sDup);'                 + CRLF +
  1083.         '  SetData;'                                     + CRLF +
  1084.         'end;'+ CRLF + CRLF, [FormIdent,SrcTable.RecordName,SrcTable.RecordName]);
  1085.  
  1086.       FmtWrite(Result,
  1087.           'procedure T%s.NeuBttnClick(Sender: TObject);' + CRLF +
  1088.           'begin'                                        + CRLF,[FormIdent]);
  1089.  
  1090.       FmtWrite(Result,
  1091.           '  if (IsModified) then begin'                 + CRLF +
  1092.           '    if JaNein('+Chr(39)+'Daten wurden nicht gespeichert'+Chr(39)+','+Chr(39)+'Trotzdem weiter ?'+Chr(39)+
  1093.           ') = False then Exit;' + CRLF +
  1094.           '  end;'                                       + CRLF +
  1095.           '  LeerData;'                                  + CRLF +
  1096.           'end;'+ CRLF + CRLF, [NIL]);
  1097.  
  1098.       NStr:= 'ModalResult:= mrOK';
  1099.  
  1100.       FmtWrite(Result,
  1101.           'procedure T%s.OkBttnClick(Sender: TObject);' + CRLF +
  1102.           'var Txt: String;'+ CRLF +
  1103.           'begin'           + CRLF,[FormIdent]);
  1104.       FmtWrite(Result,
  1105.           '  if IsModified then begin' + CRLF +
  1106.           '    if JaNein('+Chr(39)+'Daten wurden nicht gespeichert'+Chr(39)+
  1107.                ','+Chr(39)+'Trotzdem beenden ?'+Chr(39)+')' + CRLF +
  1108.           '    then ModalResult:= mrOk' + CRLF +
  1109.           '    else Exit;' + CRLF +
  1110.           '  end'          + CRLF +
  1111.           '  else %s;' + CRLF+
  1112.           'end;'+ CRLF + CRLF, [NStr]);
  1113.  
  1114.       NStr:= 'ModalResult:= mrCancel';
  1115.  
  1116.       FmtWrite(Result,
  1117.           'procedure T%s.AbbruchBttnClick(Sender: TObject);' + CRLF +
  1118.           'begin'                                            + CRLF,[FormIdent]);
  1119.       FmtWrite(Result,
  1120.           '  %s;'                        + CRLF +
  1121.           'end;'+ CRLF + CRLF, [NStr]);
  1122.  
  1123.       FmtWrite(Result,
  1124.          'procedure T%s.AendernBttnClick(Sender: TObject);' + CRLF +
  1125.          'begin'                                            + CRLF +
  1126.          '  GetData;' + CRLF +
  1127.          '  %sTable.UpdateRecord(%sData,%sDup);' + CRLF +
  1128.          '  ResetModified;' + CRLF +
  1129.          'end;' + CRLF + CRLF,[FormIdent,FormIdent,SrcTable.RecordName,SrcTable.RecordName]);
  1130.  
  1131.       FmtWrite(Result,
  1132.          'procedure T%s.AnlegBttnClick(Sender: TObject);' + CRLF +
  1133.          'begin'                                          + CRLF +
  1134.          '  GetData;'       + CRLF +
  1135.          '  %sTable.Insert(%sData,%sDup);' + CRLF +
  1136.          '  {AnlegBttn.Enabled:= False;}' + CRLF +
  1137.          '  {AendernBttn.Enabled:= True;}' + CRLF +
  1138.          '  {LoeschBttn.Enabled:= True;}' + CRLF +
  1139.          '  ResetModified;'             + CRLF +
  1140.          'end;' + CRLF + CRLF,[FormIdent,FormIdent,SrcTable.RecordName,SrcTable.RecordName]);
  1141.  
  1142.       FmtWrite(Result,
  1143.           'procedure T%s.LoeschBttnClick(Sender: TObject);' + CRLF +
  1144.           'begin'                                           + CRLF +
  1145.           '  GetData;' + CRLF +
  1146.           '  %sTable.Delete(%sData,%sDup);'                                + CRLF +
  1147.           '  {LoeschBttn.Enabled:= not(%stable.Eof);}'+ CRLF,[FormIdent,FormIdent,SrcTable.RecordName,
  1148.                                                               SrcTable.RecordName,FormIdent]);
  1149.  
  1150.       FmtWrite(Result,
  1151.           '  {AnlegBttn.Enabled:= True;}' + CRLF +
  1152.           '  {AendernBttn.Enabled:= False;}' + CRLF +
  1153.           '  ResetModified;'                                  + CRLF +
  1154.           'end;'+ CRLF + CRLF, [NIL]);
  1155.  
  1156.       FmtWrite(Result,
  1157.           'procedure T%s.SuchBttnClick(Sender: TObject);' + CRLF +
  1158.           'begin'                                         + CRLF +
  1159.           '  {}'                                          + CRLF +
  1160.           '  SetData;'                                    + CRLF +
  1161.           'end;'+ CRLF + CRLF, [FormIdent]);
  1162.  
  1163.       FmtWrite(Result,
  1164.           'procedure T%s.KeyBttnClick(Sender: TObject);' + CRLF +
  1165.           'var Liste: TStringList;'+ CRLF+
  1166.           '    Key1: Integer;'+CRLF,[FormIdent]);
  1167.       FmtWrite(Result,
  1168.           'begin'+CRLF+
  1169.           '  Key1:= %sTable.KeyNo;'+CRLF+
  1170.           '  Liste:= TStringList.Create;'+CRLF,[FormIdent]);
  1171.       if SrcTable.IsamKeyProc.Count > 0 then begin
  1172.         For i:= 0 to SrcTable.IsamKeyProc.Count-1 do begin
  1173.           NStr:= SrcTable.IsamKeyProc[i];
  1174.           if Pos('S:=',NStr) > 0 then begin
  1175.             if Pos('(',NStr) > 0 then begin
  1176.               Delete(NStr,1,Pos('(',NStr));
  1177.               if Pos(',',NStr) > 0 then begin
  1178.                 NStr:= Copy(NStr,1,Pos(',',NStr)-1);
  1179.                 FmtWrite(Result,
  1180.                   '  Liste.Add('+Chr(39)+'%s'+Chr(39)+');'+CRLF,[NStr]);
  1181.               end;
  1182.             end;
  1183.           end;
  1184.         end;
  1185.       end;
  1186.       FmtWrite(Result,
  1187.           '  Key_Einstellen(Self,Key1,Liste);'+CRLF,[NIL]);
  1188.       FmtWrite(Result,
  1189.           '  %sTable.KeyNo:= Key1;'+CRLF+
  1190.           '  Liste.Free;'+CRLF+
  1191.           'end;'+ CRLF + CRLF, [FormIdent]);
  1192.  
  1193.       FmtWrite(Result,
  1194.           'procedure T%s.%sTimerTimer(Sender: TObject);'+ CRLF +
  1195.           'var TStr: String;'+CRLF+
  1196.           'begin'+ CRLF +
  1197.           '  TStr:= '+Chr(39)+Chr(39)+';'+CRLF,[FormIdent,FormIdent]);
  1198.       FmtWrite(Result,
  1199.           '  DateTimeToString(TStr,'+Chr(39)+'dd.mm.yyyy hh:mm'+Chr(39)+',Now);'+CRLF+
  1200.           '  ZeitPanel.Caption:= TStr;' + CRLF +
  1201.           'end;'+ CRLF + CRLF, [NIL]);
  1202.  
  1203.       FmtWrite(Result,
  1204.           'Procedure T%s.ShowHint(Sender: TObject);' + CRLF +
  1205.           'begin' + CRLF +
  1206.           '  HintPanel.Caption:= Application.Hint;'  + CRLF +
  1207.           'end;' + CRLF + CRLF,[FormIdent]);
  1208.  
  1209.       FmtWrite(Result, 'end.' + CRLF, [nil]);
  1210.       Result.Position := 0;
  1211.  
  1212.     except
  1213.       Result.Free;
  1214.       raise;
  1215.     end;
  1216.  
  1217.   finally
  1218.     StrDispose(SourceBuffer);
  1219.   end;
  1220. end;
  1221.  
  1222. Constructor TEditorExperte.Create(AOwner: TComponent);
  1223. begin
  1224.   Inherited Create(aOwner);
  1225.   FTable:= TIsamTable.Create(Self);
  1226. end;
  1227.  
  1228. destructor TEditorExperte.destroy;
  1229. begin
  1230.   FTable.Free;
  1231.   Inherited destroy;
  1232. end;
  1233.  
  1234. procedure TEditorExperte.SpeedButton5Click(Sender: TObject);
  1235. begin
  1236.   if FontDialog1.Execute then EdiFontLabel.Font:= FontDialog1.Font;
  1237. end;
  1238.  
  1239. procedure TEditorExperte.SpeedButton6Click(Sender: TObject);
  1240. begin
  1241.   if FontDialog1.Execute then EdiInputFontLabel.Font:= FontDialog1.Font;
  1242. end;
  1243.  
  1244. function TEditorExperte.CreateForm(const FormIdent: string): TMemoryStream;
  1245. var DlgForm: TForm;
  1246. begin
  1247.   Result := nil;
  1248.   DlgForm := Erzeuge_EditorForm(FormNameInput.Text,
  1249.                                 FTable,
  1250.                                 LabelNebenRadio.Checked,
  1251.                                 LenFestRadio.Checked,
  1252.                                 EdiFontLabel.Font,
  1253.                                 EdiInputFontLabel.Font);
  1254.   try
  1255.     Result := TMemoryStream.Create;
  1256.     Result.WriteComponentRes(FormIdent, DlgForm);
  1257.     Result.Position := 0;
  1258.   finally
  1259.     DlgForm.Free;
  1260.   end;
  1261. end;
  1262.  
  1263. function TEditorExperte.CreateSource(const UnitIdent, FormIdent: string): TMemoryStream;
  1264. begin
  1265.   CreateSource:= Erzeuge_EditorSource(UnitIdent, FormNameInput.Text, FTable);
  1266. end;
  1267.  
  1268. procedure TEditorExperte.OKBtnClick(Sender: TObject);
  1269. var ISourceStream, IFormStream: TIMemoryStream;
  1270. begin                
  1271.   if Toolservices = NIL then Exit;
  1272.   if FormNameInput.Text = '' then Errorwindow('Formname muss angegeben werden','')
  1273.   else begin
  1274.     FormIdent:= FormNameInput.Text;
  1275.     if UnitIdent = '' then begin
  1276.       Errorwindow('UnitIdent ist nicht angegeben','');
  1277.       Exit;
  1278.     end;
  1279.     if FileName = '' then begin
  1280.       Errorwindow('Filename ist ungⁿltig','');
  1281.       Exit;
  1282.     end;
  1283.     IFormStream := TIMemoryStream.Create(CreateForm(FormIdent));
  1284.     try
  1285.       ISourceStream := TIMemoryStream.Create(CreateSource(UnitIdent, FormIdent));
  1286.       try
  1287.         ToolServices.CreateModule(FileName, ISourceStream, IFormStream,
  1288.                 [cmAddToProject, cmShowSource, cmShowForm, cmUnNamed,
  1289.                 cmMarkModified]);
  1290.       finally
  1291.         ISourceStream.OwnStream := True;
  1292.         ISourceStream.Free;
  1293.       end;
  1294.     finally
  1295.       IFormStream.OwnStream := True;
  1296.       IFormStream.Free;
  1297.     end;
  1298.   end;
  1299. end;
  1300.  
  1301. procedure TEditorExperte.FormShow(Sender: TObject);
  1302. begin
  1303.   if ToolServices = nil then Exit;
  1304.   if ToolServices.GetNewModuleName(UnitIdent, FileName) then begin
  1305.     FormIdent:= UnitIdent + 'Dialog';
  1306.     FormNameInput.Text:= FormIdent;
  1307.   end;
  1308. end;
  1309.  
  1310. end.
  1311.